new Vue({
    el:"#app",
    data: {
        fullscreenLoading:false,
        screenLoading:false,
        channelData:{
            id:null,
            channelName:'',
            channelCode:'',
            appVersion:'',
            uiType:1
        }
    },
    mounted:function () {
        var _this = this;
        var channelInfo = JSON.parse(localStorage.getItem("channelInfo"));
        if(channelInfo == null) {
            _this.$message.error("浏览器不兼容，请换高版本浏览器");
            return;
        }
        _this.channelData.channelName = channelInfo.channelName;
        _this.channelData.id = channelInfo.id;
        _this.channelData.channelCode = channelInfo.channelCode;
    },
    methods:{
        trim:function(str){
            if(isNaN(str)){
                return str.replace(/(^\s*)|(\s*$)/g, "");
            }else{
                return str
            }
        },
        saveChannelInfo:function () {
            var _this = this;
            if(_this.channelData.channelName == '' || _this.channelData.channelCode == '' || _this.channelData.appVersion == '' ) {
                _this.$message.warning("数据不完整，无法保存");
                return;
            }
            axios.post(request_prefix+"/cash/place/create",_this.channelData)
                .then(function (res) {
                    if(res.data.code === 0) {
                        _this.$message.success("保存成功,2秒中跳转到列表页");
                        setTimeout(function () {
                            window.location.href=request_prefix + "/cash/place/listPage";
                        },2000)
                    } else {
                        _this.$message.error("保存失败");
                    }
                })
                .catch(function (res) {
                    _this.$message.error("请求过程出错");
                })
        },
        toBackList:function () {
            window.location.href = request_prefix + "/cash/place/listPage";
        }

    }
});